Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/MeshBeaconRepository.kt bf5f86daaed68bdc4073fd8506dabfeb5b103420 (bf5f86da) Text, 2.35 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.repository

Tff7b72import T7ee787kotlinx.coroutines.flow.MutableStateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.StateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.asStateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.update
Tff7b72import T7ee787org.meshtastic.core.model.MeshBeaconOffer

T8b949e/**
* Holds Mesh Beacon invitations received during this app session. Beacons are advisory, ephemeral, zero-hop
* advertisements from other meshes — not messages or contacts — so they're kept in memory only (capped, no persistence)
* and naturally age out on app restart. Consumed by the Discovery surface, which presents them for the user to Discover
* / Join / Dismiss. Room persistence can be added later if users want invitations to survive restarts.
*/
Tff7b72class T56d364MeshBeaconRepository Tb4b4b4{
Tff7b72private Tff7b72val Te6edf3_offers Tff7b72= Te6edf3MutableStateFlowTff7b72<Te6edf3ListTff7b72<Te6edf3MeshBeaconOfferTff7b72>Tff7b72>Tb4b4b4(Te6edf3emptyListTb4b4b4(Tb4b4b4)Tb4b4b4)
Tff7b72val Te6edf3offersTb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3ListTff7b72<Te6edf3MeshBeaconOfferTff7b72>Tff7b72> Tff7b72= Te6edf3_offersTb4b4b4.Te6edf3asStateFlowTb4b4b4(Tb4b4b4)

T8b949e/**
* Records a received [offer], replacing any prior offer with the same [key][MeshBeaconOffer.key] (a re-broadcast of
* a standing invitation). Returns true when this is a newly-seen invitation, so the caller can notify only once
* rather than on every periodic re-broadcast.
*/
Tff7b72fun Td2a8ffaddTb4b4b4(Te6edf3offerTb4b4b4: Te6edf3MeshBeaconOfferTb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Tff7b72val Te6edf3isNew Tff7b72= Te6edf3_offersTb4b4b4.Te6edf3valueTb4b4b4.Te6edf3none Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3key Tff7b72=Tff7b72= Te6edf3offerTb4b4b4.Te6edf3key Tb4b4b4}
Te6edf3_offersTb4b4b4.Te6edf3update Tb4b4b4{ Te6edf3current Tff7b72-Tff7b72> Tb4b4b4(Te6edf3listOfTb4b4b4(Te6edf3offerTb4b4b4) Tff7b72+ Te6edf3currentTb4b4b4.Te6edf3filterNot Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3key Tff7b72=Tff7b72= Te6edf3offerTb4b4b4.Te6edf3key Tb4b4b4}Tb4b4b4)Tb4b4b4.Te6edf3takeTb4b4b4(Te6edf3MAX_OFFERSTb4b4b4) Tb4b4b4}
Tff7b72return Te6edf3isNew
Tb4b4b4}

Tff7b72fun Td2a8ffdismissTb4b4b4(Te6edf3keyTb4b4b4: Tffa657StringTb4b4b4) Tb4b4b4{
Te6edf3_offersTb4b4b4.Te6edf3update Tb4b4b4{ Te6edf3current Tff7b72-Tff7b72> Te6edf3currentTb4b4b4.Te6edf3filterNot Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3key Tff7b72=Tff7b72= Te6edf3key Tb4b4b4} Tb4b4b4}
Tb4b4b4}

Tff7b72private Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72const Tff7b72val Te6edf3MAX_OFFERS Tff7b72= T79c0ff2T79c0ff0
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.4 - Generated in 0.07s